//
// Hello server:
// 
// >curl http://localhost:3000/hello?name=Jani
// "Hello Jani"
//
// >curl http://localhost:3000/hello
// "Hello anonymous"
//

var JServer = require( '../jserver' );
var server = new JServer( {workers:1} );
server.ServerResponse.allowOrigin = '*';
if ( server.start() ) return;

server.get( "/hello", function(req,res) {
	if ( !req.query.name )
		req.query.name = 'anonymous';
	res.json( "Hello "+req.query.name );
} );

server.post( "/hello", function(req,res) {
	if ( !req.body.name )
		req.body.name = 'anonymous';
	res.json( "Hello "+req.body.name );
} );

server.listenHTTP( 3001 );
